package cn.akwangl.spring.ioc.model;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import java.io.Serializable;

/**
 * 用户Model
 *
 * @author youyongkun
 * @date 2021/6/24 14:33
 */
public class User implements Serializable, BeanNameAware {

    private String id;

    private String name;

    /**
     * 当前BeanName
     */
    private transient String beanName;

    public String getId() {
        return id;
    }

    public void init() {
        System.out.println("init User Bean [\" + beanName + \"] 初始化...");
        System.out.printf("%s 被初始化了", this.getClass().getName());
        this.id = String.valueOf(System.currentTimeMillis());
        this.name = "akwangl";
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    /**
     * 创建默认的User
     *
     * @author youyongkun
     * @date 2021/6/30 14:22
     */
    public static User createUser() {
        return new User();
    }

    @Override
    public void setBeanName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", beanName='" + beanName + '\'' +
                '}';
    }
}
